<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
/*
 * This is Hospital page.
 */
include 'config.php';
$hos = true;
?>
<html>
    <head>
        <title>Hospital</title>
        <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
        <style media="all" type="text/css">@import "css/all.css";</style>
        <meta name="google-translate-customization" content="79f814d6e23ddcf4-dfbb1fb397ca28ad-g1e3566e08575f155-1b"></meta>
    </head>
    <body>
<script type="text/javascript">
//function googleTranslateElementInit() {
//  new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
//}
</script><script type="text/javascript" src="element.js?cb=googleTranslateElementInit"></script>

        <div id="main">
            <?php include 'nav.php'; ?>
            <div id="middle">
                <div id="left-column">
                    <h3>Hospital</h3>
                    <ul class="nav">
                        <li><a href="hospital">List</a></li>
                        <li class="last" ><a href="hospital?q=new">Add New</a></li>
                    </ul>                    
                </div>

                <!--             Details starts-->
                <div id="center-column">
                    <?php if ($_GET['q'] == '') { ?>
                        <div class="top-bar">
                            <h1>Hospital List,</h1>
                            <div class="breadcrumbs"><a href="index">Homepage</a></div>
                        </div>
                        <br /><hr/> 
                        <b>This page shows you list of all Hospitals registered with SalusBank. </b><br/><br/>

                        <div class="table"  >
                            <img src="img/bg-th-left.gif" width="8" height="7" alt="" class="left" />
                            <img src="img/bg-th-right.gif" width="7" height="7" alt="" class="right" />
                            <table class="listing" cellpadding="0" cellspacing="0">
                                <tr>
                                    <th class="first">Hospital</th>                                   
                                    <th>Email</th>                                   
                                    <th>Status</th>
                                </tr>
                                <?php
                                $q2 = mysql_query("select * from salus_hospital_list ") or die(mysql_error());
                                while ($row = mysql_fetch_array($q2)) {
                                    ?>                                                          
                                    <tr class="bg" >
                                        <td class="first style1"><a href="hospital?q=detail&id=<?=$row['sr']?>" ><?= $row[2] ?></a></td>
                                        <td><?= $row['email'] ?></td>                                        
                                        <td><?php
                                            $getban = mysql_fetch_array(mysql_query("select banned from fa_user where id= $row[1]")) or die(mysql_error());
                                            if($getban['banned']==0){echo 'Active';}
                                            if($getban['banned']==1){echo 'In-Active';}                                           
                                        ?></td>                                        
                                    </tr>
                                <?php } ?>
                            </table>                        
                        </div>
                    <?php } elseif ($_GET['q'] == 'new') { ?>
                        <div class="top-bar">
                            <h1>Create New Hospital,</h1>                        
                        </div>
                        <br>
                            <form action="Com/hospital_operations.php" method="post" >
                            <br><hr>
                            <table>
                                <tr>
                                    <td>Hospital Name :</td>
                                    <td><input type="text" name="name" required /></td>
                                </tr>
                                <tr>
                                    <td>Hospital Person :</td>
                                    <td><input type="text" name="person" required /></td>
                                </tr>
                                <tr>
                                    <td>Hospital User name :</td>
                                    <td><input type="text" name="user_name" required /></td>
                                </tr>
                                <tr>
                                    <td>Hospital Password :</td>
                                    <td><input type="text" name="password" required /></td>
                                </tr>
                                
                                <tr>
                                    <td>Hospital E-mail :</td>
                                    <td><input type="text" name="email" required /></td>
                                </tr>
                                <tr>
                                    <td>Hospital Phone :</td>
                                    <td><input type="text" name="phone" required /></td>
                                </tr>
                                <tr>
                                    <td>Country :</td>
                                    <td>
                                        <select name="nation" style="width: 175px;" required >
                                        <?php
                                            $n1 = mysql_query("select * from fa_country");
                                            while ($nation1 = mysql_fetch_array($n1)) {?>
                                            <option value="<?=$nation1['id']?>" ><?=$nation1['name']?></option>  
                                        <?php }?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td><input type="hidden" name="action" value="new" /></td>
                                    <td><input type="submit" style="height: 40px;" value="Add New Hospital" /></td>
                                </tr>
                            </table>
                        </form>
                    <?php }elseif($_GET['q']=='edit'){ ?>
                        <div class="top-bar">
                            <h1>Update Hospital Detail,</h1>                        
                        </div><br><br><hr>
                        <?php $cdetail = mysql_query("select * from salus_hospital_list where sr='".$_GET['id']."'") or die(mysql_error()) ;?>
                                    <form action="Com/hospital_operations.php" method="post" >
                        <?php while($cd = mysql_fetch_array($cdetail)){ ?>
                                
                            <table>
                                <tr>
                                    <td>Hospital Name :</td>
                                    <td><input type="text" name="name" value="<?=$cd['name']?>" required /></td>
                                </tr>
                                <tr>
                                    <td>Hospital Person :</td>
                                    <td><input type="text" name="person" value="<?=$cd['person']?>" required /></td>
                                </tr>
                                
                                <tr>
                                    <td>Hospital E-mail :</td>
                                    <td><input type="text" name="email" value="<?=$cd['email']?>" required /></td>
                                </tr>
                                <tr>
                                    <td>Hospital Phone :</td>
                                    <td><input type="text" name="phone" value="<?=$cd['phone']?>" required /></td>
                                </tr>
                                <tr>
                                    <td>Country :</td>
                                    <td>
                                        <select name="nation" style="width: 175px;" required >
                                        <?php
                                            $n1 = mysql_query("select * from fa_country");
                                            while ($nation1 = mysql_fetch_array($n1)) {?>
                                            <option <?php if($cd['country']==$nation1['id']) echo 'selected'; ?>  value="<?=$nation1['id']?>" ><?=$nation1['name']?></option>  
                                        <?php }?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td><input type="hidden" name="action" value="update" />
                                        <input type="hidden" name="id" value="<?=$cd['sr']?>" /></td>
                                    <td><input type="submit" style="height: 40px;" value="Update Hospital Info" /></td>
                                </tr>
                            </table>

                        <?php }?>
                            </form>
                            <?php } elseif($_GET['q']=='detail'){ ?>
                        <div class="top-bar">
                            <h1>Hospital Detail,</h1>                        
                        </div>
                        <br /><hr/>                   
                        <?php
                        $cdetail = mysql_query("select * from salus_hospital_list where sr ='".$_GET['id']."'") or die(mysql_error()) ;
                        while($cd = mysql_fetch_array($cdetail)){
                        ?>
                        
                            <table>
                                <tr>
                                    <td>Hospital Name :</td>
                                    <td><b><?=$cd['name']?></b></td>
                                </tr>
                                <tr>
                                    <td>Hospital Person :</td>
                                    <td><b><?=$cd['person']?></b></td>
                                </tr>
                                
                                <tr>
                                    <td>Hospital E-mail :</td>
                                    <td><b><?=$cd['email']?></b></td>
                                </tr>
                                <tr>
                                    <td>Hospital Phone :</td>
                                    <td><b><?=$cd['phone']?></b></td>
                                </tr>
                                <tr>
                                    <td>Country :</td>
                                    <td><b>
                                       
                                        <?php
                                            $n1 = mysql_query("select * from fa_country where id='".$cd['country']."' ");
                                            while ($nation1 = mysql_fetch_array($n1)) {
                                                echo $nation1['name'];
                                            }?></b>                                       
                                    </td>                                    
                                </tr>    
                                <tr>
                                    <td>User Name :</td>
                                    <td><?php 
                                    $hid = $cd['hospital_id'];
                                    $username = mysql_fetch_array(mysql_query("select * from fa_user where id= $hid "));
                                    echo $username['user_name'];
                                    $banned = $username['banned'];
                                    ?></td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td><a href="hospital?q=edit&id=<?=$cd['sr']?>"><img src="img/edit-icon.gif" title="Edit Hospital Info" /></a>
                                        <?php
                                        if($banned==0){?>
                                            <a href="hospital?q=b&id=<?=$cd['hospital_id']?>"><img src="img/banned.jpg" title="In-Active/Banned This Hospital" /></a></td>
                                       <?php }else{?>
                                    <a href="hospital?q=a&id=<?=$cd['hospital_id']?>"><img src="img/approve.jpg" title="Active/Un-Banned This Hospital" /></a></td>
                                       <?php }
                                        ?>
                                        
                                </tr>
                            </table><br/><hr/>                             
                            
                        <?php  } } elseif($_GET['q']=='a'){
                                  mysql_query("update fa_user set banned= 0 where id='".$_GET['id']."' ") or die(mysql_error());
                                  header('Location:hospital');
                            }elseif($_GET['q']=='b'){
                                  mysql_query("update fa_user set banned= 1 where id='".$_GET['id']."' ") or die(mysql_error());
                                  header('Location:hospital');
                            } ?>
                </div>
                <div id="right-column">
                    <strong class="h">INFO</strong>
                    <div class="box">Welcome to Adminpanel.<br> Add Hospital, give them rites. </div><br/><br/><br/><br/>
                   <div id="google_translate_element"></div>
                </div>
                
            </div>
            <div id="footer">Developed By SpearBall Inc. : Savan Koradia</div>
        </div>


    </body>   
</html>